package main.java.indi.zyj.coderecord;

import main.java.indi.zyj.hot100.base.TreeNode;

public class SumOfLeftLeaves {

    int res = 0;
    public int sumOfLeftLeaves(TreeNode root) {

        dfs(root);

        return res;

    }

    private void dfs(TreeNode root) {
        if (root == null) {
            return;
        }
        if (root.left != null && root.left.left == null && root.left.right == null) {
            res += root.left.val;
        }
        dfs(root.left);
        dfs(root.right);
    }

}
